package com.itheima.aop;/*
package com.itheima.aop;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.itheima.mapper.OperateLogMapper;
import com.itheima.pojo.OperateLog;
import com.itheima.utils.CurrentHolder;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

*/
/**
 * @Author：cxl
 * @Package：com.itheima.aop
 * @Project：web-project
 * @name：OperateLogAspect2
 * @Date：2025/10/7 16:46
 * @Filename：OperateLogAspect2
 *//*

@Slf4j
@Aspect
@Component
public class OperateLogAspect2 {
    @Autowired
    private OperateLogMapper operateLogMapper;

    @Around("@annotation(com.itheima.aop.annotation.LogOperater)")
    public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
        long start = System.currentTimeMillis();
        Object result = null;
        OperateLog operateLog = new OperateLog();
        operateLog.setOperateEmpId(CurrentHolder.getCurrentId());
        operateLog.setOperateTime(LocalDateTime.now());
        operateLog.setClassName(joinPoint.getTarget().getClass().getName());
        operateLog.setClassName(joinPoint.getSignature().getName());
        operateLog.setMethodName(new ObjectMapper().writeValueAsString(joinPoint.getArgs()));
        try {
            result = joinPoint.proceed();
            long end = System.currentTimeMillis();
            operateLog.setReturnValue(result.toString());
            operateLog.setCostTime(end-start);
        } catch (Throwable e) {
            throw new RuntimeException(e);
        } finally {
            operateLogMapper.insert(operateLog);
        }
        return result;
    }
}
*/

